package ru.paswd.marketprice.rest.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import ru.paswd.marketprice.rest.api.dto.*;

import java.util.List;
import java.util.UUID;

@Api(tags = "Product")
@RequestMapping("/api/v1/product")
public interface ProductApi {

    @ApiOperation("Get product categories")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @GetMapping("categories")
    List<ProductCategory> getProductCategories();

    @ApiOperation("Get product list")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @GetMapping("products")
    PageResponse<Product> getProducts(
            @RequestParam(name = "name", required = false) String name,
            @RequestParam(name = "category", required = false) String category,
            Pageable pageable
    );

    @ApiOperation("Get product price list")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @GetMapping("priceList")
    List<PriceWithShop> getPriceList(
            @RequestParam(name = "productId") UUID productId,
            @RequestParam(name = "radiusMeters", required = false) Integer radiusMeters,
            @RequestParam(name = "lat") Double lat,
            @RequestParam(name = "lng") Double lng,
            @RequestParam(name = "sortByPrice") Boolean sortByPrice
    );

    @ApiOperation("Save receipt")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @PutMapping("save")
    void saveReceipt(
            @RequestBody ReceiptInfo receiptInfo
    );

    @ApiOperation("Get price history")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @GetMapping("priceHistory")
    List<Price> getPriceHistory(
            @RequestParam(name = "shopId") UUID shopId,
            @RequestParam(name = "productId") UUID productId
    );
}
